package com.niuwa.p2p.action.accountflowmanager;
import java.util.Map;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.springframework.beans.factory.annotation.Autowired;

import com.niuwa.p2p.action.JsonAction;
import com.niuwa.p2p.core.mvc.entity.PageBean;
import com.niuwa.p2p.entity.customer.Customer;
import com.niuwa.p2p.entity.fund.AccountFlow;
import com.niuwa.p2p.service.customer.ICustomerService;
import com.niuwa.p2p.service.fund.IAccountFlowManagerService;

/**
 * 
 * @ClassName: UserAction
 * @Descriptio 用户Action
 * @author:    jishengjun
 * 
 */

public class AccountFlowManagerAction extends JsonAction{

	private static final long serialVersionUID = -8900124777631535966L;

	/** 日志 */
	private static Logger logger = Logger.getLogger(AccountFlowManagerAction.class);
	
	
	@Autowired
	private  IAccountFlowManagerService   accountFlowManagerService;
	
	@Autowired
	private ICustomerService customerService;

/**************************************************************************牛娃资金账户流水开始**********************************************************************************************************************/
	/**
	 * 
	 *跳转到牛娃资金流水页面
	 *
	 */
	@Action(value="nwAccountFlow")
	public String gotoNwAccountFlowPage(){
		return "nwAccountFlow";	
	}
	
	

	/**
	 *查询牛娃账户列表
	 * @return
	 * @throws Exception
	 */

	@Action(value="searchNwAccountFlow")
	public String searchNwAccountFlow() throws Exception {
		setObjectReSult(queryNwAccountPage());
		logger.info("nwAccountList action execute success");
		return NONE;
	}
	
	
	/**
	 * 分页查询牛娃账户列表
	 * 
	 * @return Pagination<AccountFlow> 
	 */
	private PageBean<AccountFlow> queryNwAccountPage() {

		// 获取查询参数
		Map<String, Object> paramMap = getParamMap();
		
		paramMap.put("acctKind", "NW");

		// 查选分页集合
		PageBean<AccountFlow> page =  accountFlowManagerService.searchNwAccountFlow(paramMap);
		
		return page;
	}
	
	
	/**************************************************************************牛娃资金账户流水结束**********************************************************************************************************************/
	

	
	/**************************************************************************客户资金账户流水开始**********************************************************************************************************************/
	/**
	 * 
	 *跳转到客户账户流水页面
	 *
	 */
	@Action(value="customerAccountFlow")
	public String gotoCustomerAccountFlowPage(){
		String acctName = getParam("acctName");
		if(acctName == null){
			acctName = "";
		}
		this.getRequest().setAttribute("acctName", acctName);
		return "customerAccountFlow";	
	}
	
	/**
	 *查询客户资金流水列表
	 * @return
	 * @throws Exception
	 */

	@Action(value="searchCustomerAccountFlow")
	public String searchCustomerAccountFlow() throws Exception {
		setObjectReSult(queryCustomerAccountPage());
		logger.info("nwAccountList action execute success");
		return NONE;
	}
	
	
	/**
	 * 分页查询客户资金账户流水
	 * 
	 * @return Pagination<AccountFlow> 
	 */
	private PageBean<AccountFlow> queryCustomerAccountPage() {
     
		 
		// 获取查询参数
		Map<String, Object> paramMap = getParamMap();
		
		paramMap.put("acctKind", "CUST");

		// 查选分页集合
		PageBean<AccountFlow> page =  accountFlowManagerService.searchNwAccountFlow(paramMap);
		
		return page;
	}
	
	
	
	
	
	/**************************************************************************客户资金账户流水结束**********************************************************************************************************************/	
	
	
	
	/**************************************************************************渠道资金账户流水开始**********************************************************************************************************************/
	/**
	 * 
	 *跳转到渠道账户流水页面
	 *
	 */
	@Action(value="chlAccountFlow")
	public String gotoChannelAccountFlowPage(){
		String acctName = getParam("acctName");
		if(acctName == null){
			acctName = "";
		}
		this.getRequest().setAttribute("acctName", acctName);
		return "channelAccountFlow";	
	}
	
	/**
	 *查询渠道资金流水列表
	 * @return
	 * @throws Exception
	 */

	@Action(value="searchChannelAccountFlow")
	public String searchChannelAccountFlow() throws Exception {
		setObjectReSult(queryChannelAccountPage());
		logger.info("channelAccountList action execute success");
		return NONE;
	}
	
	
	/**
	 * 分页查询渠道资金账户流水
	 * 
	 * @return Pagination<AccountFlow> 
	 */
	private PageBean<AccountFlow> queryChannelAccountPage() {
     
		 
		// 获取查询参数
		Map<String, Object> paramMap = getParamMap();
		
		paramMap.put("acctKind", "CHL");

		// 查选分页集合
		PageBean<AccountFlow> page =  accountFlowManagerService.searchNwAccountFlow(paramMap);
		
		return page;
	}
	
	
	
	
	
	/**************************************************************************渠道资金账户流水结束**********************************************************************************************************************/	
	
	
	
	public IAccountFlowManagerService getAccountFlowManagerService() {
		return accountFlowManagerService;
	}

	public void setAccountFlowManagerService(
			IAccountFlowManagerService accountFlowManagerService) {
		this.accountFlowManagerService = accountFlowManagerService;
	}
}
